#include "readthread.h"
#include <QDebug>

ReadThread::ReadThread(QReadWriteLock * lock):
    QThread()
    ,readWriteLock(lock)
{

}

void ReadThread::run()
{
    qDebug() << QStringLiteral("读线程进来了：")<<"thread id ="
    <<QThread::currentThreadId();

    while (!stop) {
        readWriteLock->lockForRead();
        qDebug() << "thread id =" <<QThread::currentThreadId()
                 <<QStringLiteral("开始读");
        QThread::sleep(1);
        qDebug() << "thread id =" <<QThread::currentThreadId()
                 <<QStringLiteral("读完了");
        readWriteLock->unlock();
    }

}
